package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BasicCustomer;
import com.bzkj.basicinfo.service.basic.BasicCustomerService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：swj
 * @Desc wms客商管理
 * @Date：2025/9/28 17:08
 */
@Api(tags = "客商管理")
@RestController
@RequestMapping("/basic/customer")
public class BasicCustomerController extends BaseController {
    @Autowired
    private BasicCustomerService customerService;

    @ApiOperation("查询接口")
    @GetMapping("/queryList")
    public TableDataInfo findNccBasicCustomerDataPage(BasicCustomer customer) {
        startPage();
        return getDataTable(customerService.listByCondition(customer));
    }

    @ApiOperation("查询接口")
    @GetMapping("/queryAllList")
    public AjaxResult findAllBasicCustomerData(BasicCustomer customer) {
        return AjaxResult.success(customerService.listByCondition(customer));
    }

    @ApiOperation("新增接口")
    @LogC(title = "客商管理",businessType = BusinessType.INSERT,tableNames = "basic_customer",
    pkFieldNames = "id",content = "'单位名称：'+#customer.customerName")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BasicCustomer customer) {
        return AjaxResult.success(customerService.add(customer));
    }

    @ApiOperation("修改接口")
    @LogC(title = "客商管理",businessType = BusinessType.UPDATE,tableNames = "basic_customer",
            pkFieldNames = "id",content = "'单位名称：'+#customer.customerName")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody BasicCustomer customer) {
        return AjaxResult.success(customerService.update(customer));
    }

    @ApiOperation("修改状态接口")
//    @LogC(title = "客商管理",businessType = BusinessType.UPDATE)
    @PostMapping("/updateState")
    public AjaxResult updateState(@RequestParam String id,@RequestParam String state) {
        return AjaxResult.success(customerService.updateState(id,state));
    }

    @ApiOperation("删除接口")
    @LogC(title = "客商管理",businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestParam String id) {
        return AjaxResult.success(customerService.delete(id));
    }
}
